<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script>
			
			function  game(i){
				var obj=document.getElementById("num"+i);
				obj.style.color="blue";
				if(i%2==0){
					obj.style.color="red";
				}
				alert("按钮"+i);
			}
			
			window.onload=game1;
			
			function  game1(){
				 var list=document.getElementsByTagName("p");
				 for(var i=0;i<list.length;i++){
				 	if(i%2==0){
				 		  list[i].style.backgroundColor="blue";
				 	}else{
				 		 list[i].style.backgroundColor="red";
				 	}
				 }
			}
		</script>
	</head>
	<body>
		<button onclick="game(1)" id="num1">按钮一</button><br /><br />
		<button onclick="game(2)" id="num2">按钮二</button><br /><br />
		<button onclick="game(3)" id="num3">按钮三</button><br /><br />
		<button onclick="game(4)" id="num4">按钮四</button><br /><br />
		<button onclick="game(5)" id="num5">按钮五</button><br /><br />
		<button onclick="game(6)" id="num6">按钮六</button><br /><br />
		<button onclick="game(7)" id="num7">按钮七</button><br /><br />
		<button onclick="game(8)" id="num8">按钮八</button><br /><br />
		
		
		<p onlick="game1(this)">段落1</p><br /><br />
		<p onlick="game1(this)">段落2</p><br /><br />
		<p onlick="game1(this)">段落3</p><br /><br />
		<p onlick="game1(this)">段落4</p><br /><br />
		<p onlick="game1(this)">段落5</p><br /><br />
		<p onlick="game1(this)">段落6</p><br /><br />
		<p onlick="game1(this)">段落7</p><br /><br />
		<p onlick="game1(this)">段落8</p><br /><br />
		
	</body>
</html>
